<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025/2/17
  Time: 11:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>Title</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<form id="formId" method="post">
  用户名: <input type="text" name="name"><br>
  密码: <input type="text" name="password"><br>
  验证码: <input type="text" name="code"> <img src="/verifyCode"><br>
  <input type="button" onclick="submitForm()" value="登录">
</form>
<script src="/static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/mylayer.js" type="text/javascript" charset="utf-8"></script>
<script>
  function submitForm() {
    $.post(
            '/user?method=login',
            $('#formId').serialize(), //{"name":"zhangsan","age":23}
            function (result) {
              console.log(result);
              if (result.code == 0) {
                mylayer.okUrl(result.msg, '/');
              } else {
                mylayer.errorMsg(result.msg);
              }
            },
            'json'
    );
  }
</script>
</body>
</html>